﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Util.Props
{
    /// <summary>
    /// An default (abstract) implementation of a configurable that implements a meaning {@code toString()} and keeps a
    /// references to the {@code Confurable}'s logger.
    ///
    /// @author Holger Brandl
    /// </summary>
    public abstract class ConfigurableAdapter : IConfigurable
    {
        private String name;

        public ConfigurableAdapter() 
        {
        }

        virtual public void newProperties(PropertySheet ps)
        {
            init(ps.InstanceName);
        }

        private void init(String name) 
        {
            this.name = name;
        }

        /** Returns the configuration name this {@code Configurable}. */
        public String getName() 
        {
            // fix null names
            return name != null ? name : GetType().Name;
        }


        /**
        /// Returns the name of this BaseDataProcessor.
         *
        /// @return the name of this BaseDataProcessor
         */
        override
        public String ToString() 
        {
            return getName();
        }

        void IConfigurable.newProperties(PropertySheet ps)
        {
            newProperties(ps);
        }
    }
}
